CREATE TABLE [dbo].[TMDOCU_CLIE]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[CO_CLIE] [dbo].[TD_VC_020] NOT NULL,
[CO_TIPO_DOCU] [dbo].[TD_VC_003] NOT NULL,
[NU_DOCU_CLIE] [dbo].[TD_VC_020] NOT NULL,
[CO_TIPO_OPER] [dbo].[TD_VC_003] NULL,
[CO_COND_PAGO] [dbo].[TD_VC_003] NOT NULL,
[FE_EMIS] [dbo].[TD_DT_001] NOT NULL,
[NU_ASTO] [dbo].[TD_VC_010] NULL,
[CO_UNID_CONC] [dbo].[TD_VC_003] NOT NULL,
[FE_VENC] [dbo].[TD_DT_001] NOT NULL,
[FE_PRES] [dbo].[TD_DT_001] NULL,
[FA_TIPO_CAMB] [dbo].[TD_NU_015_006] NOT NULL CONSTRAINT [DF__TMDOCU_CL__FA_TI__5DD5DC5C] DEFAULT ((1.000)),
[CO_MONE] [dbo].[TD_VC_003] NOT NULL,
[FA_CAMB_EXTR] [dbo].[TD_NU_015_006] NULL,
[FE_PROG_COBR] [dbo].[TD_DT_001] NULL,
[IM_BRUT_AFEC] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__IM_BR__5ECA0095] DEFAULT ((0)),
[IM_BRUT_INAF] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__IM_BR__5FBE24CE] DEFAULT ((0)),
[IM_GAFI] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__IM_GA__60B24907] DEFAULT ((0)),
[IM_MORA] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__IM_MO__61A66D40] DEFAULT ((0)),
[IM_FLET] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__IM_FL__629A9179] DEFAULT ((0)),
[ST_AFEC_GAFI] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_AF__638EB5B2] DEFAULT ('N'),
[ST_AFEC_MORA] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_AF__6576FE24] DEFAULT ('N'),
[ST_AFEC_FLET] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_AF__675F4696] DEFAULT ('N'),
[ST_DCT1_BRAF] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_DC__69478F08] DEFAULT ('N'),
[ST_DCT1_BRIN] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_DC__6B2FD77A] DEFAULT ('N'),
[ST_DCT1_GAFI] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_DC__6D181FEC] DEFAULT ('N'),
[ST_DCT1_MORA] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_DC__6F00685E] DEFAULT ('N'),
[ST_DCT1_FLET] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_DC__70E8B0D0] DEFAULT ('N'),
[ST_DCT2_BRAF] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_DC__72D0F942] DEFAULT ('N'),
[ST_DCT2_BRIN] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_DC__74B941B4] DEFAULT ('N'),
[ST_DCT2_GAFI] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_DC__76A18A26] DEFAULT ('N'),
[ST_DCT2_MORA] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_DC__7889D298] DEFAULT ('N'),
[ST_DCT2_FLET] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_DC__7A721B0A] DEFAULT ('N'),
[PC_DCT1] [dbo].[TD_NU_009_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__PC_DC__7C5A637C] DEFAULT ((0)),
[IM_DCT1] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__IM_DC__7D4E87B5] DEFAULT ((0)),
[PC_DCT2] [dbo].[TD_NU_009_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__PC_DC__7E42ABEE] DEFAULT ((0)),
[IM_DCT2] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__IM_DC__7F36D027] DEFAULT ((0)),
[PC_IMP1] [dbo].[TD_NU_009_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__PC_IM__002AF460] DEFAULT ((0)),
[IM_IMP1] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__IM_IM__011F1899] DEFAULT ((0)),
[CO_IMP1] [dbo].[TD_VC_003] NULL,
[PC_IMP2] [dbo].[TD_NU_009_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__PC_IM__02133CD2] DEFAULT ((0)),
[IM_IMP2] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__IM_IM__0307610B] DEFAULT ((0)),
[CO_IMP2] [dbo].[TD_VC_003] NULL,
[PC_IMP3] [dbo].[TD_NU_009_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__PC_IM__03FB8544] DEFAULT ((0)),
[IM_IMP3] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__IM_IM__04EFA97D] DEFAULT ((0)),
[CO_IMP3] [dbo].[TD_VC_003] NULL,
[IM_TOTA] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__IM_TO__05E3CDB6] DEFAULT ((0)),
[IM_PAGA] [dbo].[TD_NU_016_004] NOT NULL CONSTRAINT [DF__TMDOCU_CL__IM_PA__06D7F1EF] DEFAULT ((0)),
[TI_DOCU_ORIG] [dbo].[TD_VC_003] NULL,
[NU_DOCU_ORIG] [dbo].[TD_VC_020] NULL,
[FE_DOCU_ORIG] [dbo].[TD_DT_001] NULL,
[ST_CONT] [dbo].[TD_VC_001_INTE] NOT NULL CONSTRAINT [DF__TMDOCU_CL__ST_CO__07CC1628] DEFAULT ('N'),
[CO_ESTA_DOCU] [dbo].[TD_VC_003] NULL,
[NU_REND_GAST] [dbo].[TD_VC_010] NULL,
[NU_CANJ] [dbo].[TD_VC_008] NULL,
[CO_LIQU] [dbo].[TD_VC_020] NULL,
[NU_RENO] [dbo].[TD_VC_008] NULL,
[FE_DESP] [dbo].[TD_DT_001] NULL,
[CO_MODE_DIST] [dbo].[TD_VC_003] NULL,
[NU_PROC] [dbo].[TD_IN_001] NULL CONSTRAINT [DF__TMDOCU_CL__NU_PR__09B45E9A] DEFAULT ((0)),
[NU_AMAR] [dbo].[TD_VC_008] NULL,
[TI_VEND] [dbo].[TD_VC_003] NULL,
[DE_DIRE] [dbo].[TD_VC_100] NULL,
[FE_AMAR] [dbo].[TD_DT_001] NULL,
[CO_VEND] [dbo].[TD_VC_020] NULL,
[DE_OBSE] [dbo].[TD_VC_100] NULL,
[DE_OBSE_0001] [dbo].[TD_VC_100] NULL,
[DE_OBSE_0002] [dbo].[TD_VC_100] NULL,
[TI_CLIE] [dbo].[TD_VC_003] NULL,
[NU_RUCS] [dbo].[TD_VC_020] NULL,
[NU_PEDI] [dbo].[TD_VC_020] NULL,
[CO_BANC] [dbo].[TD_VC_003] NULL,
[CO_TIPO_FINA] [dbo].[TD_VC_003] NULL,
[NU_UNIC_BANC] [dbo].[TD_VC_020] NULL,
[CO_COND_FINA] [dbo].[TD_VC_003] NULL,
[FE_SALI_EMBQ] [dbo].[TD_DT_001] NULL,
[CO_DEST] [dbo].[TD_VC_003] NULL,
[NU_DEST] [dbo].[TD_VC_003] NULL,
[ST_AFEC_IISC] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_AF__0AA882D3] DEFAULT ('N'),
[ST_AFEC_PERC] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_AF__0C90CB45] DEFAULT ('N'),
[TI_VENT] [dbo].[TD_VC_003] NULL,
[ST_PERC] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_PE__0E7913B7] DEFAULT ('N'),
[PC_PERC] [dbo].[TD_NU_009_004] NULL CONSTRAINT [DF__TMDOCU_CL__PC_PE__0F6D37F0] DEFAULT ((0)),
[IM_TOTA_SPER] [dbo].[TD_NU_016_004] NULL CONSTRAINT [DF__TMDOCU_CL__IM_TO__10615C29] DEFAULT ((0)),
[CO_CNTA_CLIE] [dbo].[TD_VC_020] NULL,
[ST_DCT1_BREX] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_DC__11558062] DEFAULT ('N'),
[ST_DCT2_BREX] [dbo].[TD_VC_001_SINO] NULL CONSTRAINT [DF__TMDOCU_CL__ST_DC__133DC8D4] DEFAULT ('N'),
[IM_BRUT_EXON] [dbo].[TD_NU_016_004] NULL CONSTRAINT [DF__TMDOCU_CL__IM_BR__15261146] DEFAULT ((0)),
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL CONSTRAINT [DF__TMDOCU_CL__CO_US__161A357F] DEFAULT (suser_sname()),
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TMDOCU_CL__FE_US__170E59B8] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL CONSTRAINT [DF__TMDOCU_CL__CO_US__18027DF1] DEFAULT (suser_sname()),
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TMDOCU_CL__FE_US__18F6A22A] DEFAULT (getdate()),
[NO_CLIE] [dbo].[TD_VC_100] NULL,
[CO_SUBR] [dbo].[TD_VC_003] NULL,
[CO_TIEN] [dbo].[TD_VC_020] NULL,
[CO_MONE_FACT] [dbo].[TD_VC_003] NULL,
[CO_AUXI_EMPR] [dbo].[TD_VC_020] NULL,
[ST_TRAN_GRAT] [dbo].[TD_VC_001] NULL,
[NU_COMP_CAJA] [dbo].[TD_VC_010] NULL,
[CO_CAJA] [dbo].[TD_VC_008] NULL,
[AA_CAJA] [dbo].[TD_VC_004] NULL,
[MM_CAJA] [dbo].[TD_VC_002] NULL,
[NU_PROC_CARG] [dbo].[TD_IN_001] NULL CONSTRAINT [DF__TMDOCU_CL__NU_PR__19EAC663] DEFAULT ((0)),
[TI_FACT] [dbo].[TD_VC_003] NULL,
[ST_SUJE_DETR] [dbo].[TD_VC_001_SINO] NULL,
[CO_ACTI_DETR] [dbo].[TD_VC_003] NULL,
[PO_DETR] [dbo].[TD_NU_009_004] NULL,
[CO_TIOP_DETR] [dbo].[TD_VC_003] NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
CREATE  Trigger [dbo].[tD_TMDOCU_CLIE_D01] on [dbo].[TMDOCU_CLIE] for DELETE
/*---------------------------------------------------------*/
/*---- Empresa              : OFISIS S.A.              ----*/
/*---- Cliente              : OFISIS S.A.              ----*/
/*---- Sistema              : OFITESO                  ----*/
/*---- M½dulo               : Inventarios              ----*/
/*---- Programa             : Trigger                  ----*/
/*---- Script               : TRIGGERS_TMDOCU_CLIE.SQL ----*/
/*---- Nombre TR            : tD_TMDOCU_CLIE_D01       ----*/
/*---- Desarrollado por     : Carlos Marquez Escobar   ----*/
/*---- Fecha Creaci½n       : 22/09/2005              ----*/
/*---- Base de Datos        : SQL	                   ----*/
/*---- Versi½n              : 8.1                      ----*/
/*---- Invoca a SP          :                          ----*/
/*---------------------------------------------------------*/
/*---- Modificado 1 por     :                          ----*/
/*---- Fecha Modificaci½n   :                          ----*/    
/*---- Detalle Modificacicn :                          ----*/  
/*---------------------------------------------------------*/
/*---- Comentarios: actualiza la Bitacora Docs Elimina ----*/
/*----                                                 ----*/
/*----                                                 ----*/
/*---------------------------------------------------------*/
/*---- Drop TRIGGER tD_TMDOCU_CLIE_D01                 ----*/
/*---- Grant All On tD_TMDOCU_CLIE_D01 to PUBLIC       ----*/
/*---------------------------------------------------------*/
As
Begin 
  Declare 
  @CSCO_EMPR	    TD_VC_002,
  @CSCO_CLAV_TAOR	    TD_VC_100,
  @CSCO_CLIE                 TD_VC_020, 
  @CSCO_TIPO_DOCU      TD_VC_003, 
  @CSNU_DOCU_CLIE    TD_VC_020

  Declare  CT_TMDOCU_CLIE_D01_1 Cursor 
  For 
  Select   CO_EMPR, 
		Replicate (' ', 20 - Len(RTrim(Ltrim(IsNull(CO_CLIE,''))))) + RTrim(Ltrim(IsNull(CO_CLIE,''))) + 
		Replicate (' ', 03 - Len(RTrim(Ltrim(IsNull(CO_TIPO_DOCU,''))))) + RTrim(Ltrim(IsNull(CO_TIPO_DOCU,''))) +
		Replicate (' ', 20 - Len(RTrim(Ltrim(IsNull(NU_DOCU_CLIE,''))))) + RTrim(Ltrim(IsNull(NU_DOCU_CLIE,''))) +
		Replicate (' ', 10 - Len(RTrim(Ltrim(IsNull(NU_ASTO,''))))) + RTrim(Ltrim(IsNull(NU_ASTO,''))) +
		Replicate (' ', 03 - Len(RTrim(Ltrim(IsNull(CO_ESTA_DOCU,''))))) + RTrim(Ltrim(IsNull(CO_ESTA_DOCU,''))), CO_CLIE, CO_TIPO_DOCU, NU_DOCU_CLIE
  From     Deleted

  Open    CT_TMDOCU_CLIE_D01_1
  Fetch   CT_TMDOCU_CLIE_D01_1 Into
          @CSCO_EMPR, @CSCO_CLAV_TAOR, @CSCO_CLIE, @CSCO_TIPO_DOCU, @CSNU_DOCU_CLIE
  While @@Fetch_Status = 0
  Begin
    If @@Fetch_Status < 0
      Begin
        Close CT_TMDOCU_CLIE_D01_1
        Deallocate tD_TMDOCU_CLIE_D01_1
      End

	IF	Not exists ( Select  CO_CLAV_TAOR From TMREGI_ELIM Where CO_EMPR = @CSCO_EMPR and CO_TABL_ORIG = 90 and 
					CO_CLAV_TAOR = RTRIM( @CSCO_EMPR )+ REPLICATE('#', 2-LEN(RTRIM(@CSCO_EMPR)))+ RTRIM( @CSCO_TIPO_DOCU )+ REPLICATE('#', 3-LEN(RTRIM(@CSCO_TIPO_DOCU)))+ RTRIM( @CSNU_DOCU_CLIE )+ REPLICATE('#', 15-LEN(RTRIM(@CSNU_DOCU_CLIE)))
					) And
		Not exists ( Select  CO_CLAV_TAOR From TMREGI_ELIM Where CO_EMPR = @CSCO_EMPR and CO_TABL_ORIG = 83 and DE_TABL_ORIG = 'MAESTRO DOCUMENTOS CLIENTES' And
					CO_CLAV_TAOR = RTRIM( @CSCO_EMPR )+ REPLICATE('#', 2-LEN(RTRIM(@CSCO_EMPR)))+ RTRIM( @CSCO_TIPO_DOCU )+ REPLICATE('#', 3-LEN(RTRIM(@CSCO_TIPO_DOCU)))+ RTRIM( @CSNU_DOCU_CLIE )+ REPLICATE('#', 15-LEN(RTRIM(@CSNU_DOCU_CLIE)))
					) 	 
		Insert Into TMREGI_ELIM 
		(CO_EMPR, CO_TABL_ORIG, DE_TABL_ORIG, CO_CLAV_TAOR)
		Values 
		(@CSCO_EMPR, 83, 'MAESTRO CLIENTES POR FUERA', @CSCO_CLAV_TAOR)

	  Fetch   CT_TMDOCU_CLIE_D01_1 Into
	          @CSCO_EMPR, @CSCO_CLAV_TAOR, @CSCO_CLIE, @CSCO_TIPO_DOCU, @CSNU_DOCU_CLIE
  End -- Del Cursor
  Close CT_TMDOCU_CLIE_D01_1
  Deallocate CT_TMDOCU_CLIE_D01_1
End
/*---------------------------Fin------------------------*/

GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE Trigger [dbo].[TU_TMDOCU_CLIE_U02] On [dbo].[TMDOCU_CLIE]      
For Update      
/*---------------------------------------------------------*/      
/*---- Empresa              : OFISIS S.A.              ----*/      
/*---- Cliente              : OFISIS S.A.              ----*/      
/*---- Sistema              : OFITESO                  ----*/      
/*---- Módulo               : TESORERIA                ----*/      
/*---- Programa             : DOCUMENTOS CLIENTES      ----*/      
/*---- Script               : TRIGGERS_TMDOCU_CLIE.SQL ----*/      
/*---- Nombre TR            : TU_TMDOCU_CLIE_U02       ----*/      
/*---- Desarrollado por     : Javier Flores A.         ----*/      
/*---- Fecha Creación       : 09/05/2003               ----*/      
/*---- Base de Datos        : SQL                      ----*/      
/*---- Versión              : 8.0                      ----*/      
/*---- Invoca a SP          :                          ----*/      
/*---------------------------------------------------------*/      
/*---- Modificado 1 por     :                          ----*/      
/*---- Fecha Modificación   :                          ----*/          
/*---- Detalle Modificacicn :                          ----*/        
/*---------------------------------------------------------*/      
/*---- Comentarios: Actualiza datos en tabla ventas    ----*/      
/*----                                                 ----*/      
/*---------------------------------------------------------*/      
/*---- Se ejecuta con el update de la Tabla            ----*/      
/*---------------------------------------------------------*/      
As      
If Update(CO_ESTA_DOCU) Or Update(IM_PAGA)       
  /*
IF ( (SELECT trigger_nestlevel() ) < 2 )  
 and   ( isnull((SELECT trigger_nestlevel( object_ID('[SIRIUS].[OFIVENT].[dbo].[TI_TCDOCU_CLIE_U01]') ) ),0) = 0  
 )  */
  
Begin      
  Declare       
  @CSCO_EMPR  TD_VC_002,        
  @CSTI_DOCU  TD_VC_003,      
  @CSNU_DOCU  TD_VC_020,      
  @CSCO_USUA_MODI TD_VC_008,      
  @CDFE_USUA_MODI TD_DT_001,      
  
  @CSST_PAGO_VNTA  TD_VC_001,      
  @CNIM_PAGA            TD_NU_016_004,      
  @CSCO_ESTA_DOCU       TD_VC_003      
      
  Declare CT_TMDOCU_CLIE_U02_1 Cursor      
  For      
  Select CO_EMPR,   CO_TIPO_DOCU,      
  NU_DOCU_CLIE,   IM_PAGA, CO_ESTA_DOCU,    
  CO_USUA_MODI,          FE_USUA_MODI      
  From inserted      
      
  Open  CT_TMDOCU_CLIE_U02_1      
  Fetch CT_TMDOCU_CLIE_U02_1 Into @CSCO_EMPR,@CSTI_DOCU, @CSNU_DOCU,      
  @CNIM_PAGA,@CSCO_ESTA_DOCU, @CSCO_USUA_MODI,@CDFE_USUA_MODI      
      
  While @@Fetch_Status = 0      
  Begin      
    If  @@Fetch_Status < 0      
      Begin      
        Close CT_TMDOCU_CLIE_U02_1      
        Deallocate CT_TMDOCU_CLIE_U02_1      
      End      
      
  
   Update [OFIVENT].[DBO].TCDOCU_CLIE      
       SET CO_ESTA_DOCU    =  @CSCO_ESTA_DOCU,      
           IM_PAGA         =  Isnull(@CNIM_PAGA,0),       
           CO_USUA_MODI =  @CSCO_USUA_MODI,      
     FE_USUA_MODI =  @CDFE_USUA_MODI      
       Where CO_EMPR = @CSCO_EMPR      
       AND TI_DOCU = @CSTI_DOCU      
       AND NU_DOCU = @CSNU_DOCU 

      
     Fetch CT_TMDOCU_CLIE_U02_1 Into      
     @CSCO_EMPR,@CSTI_DOCU ,@CSNU_DOCU,@CNIM_PAGA,
 @CSCO_ESTA_DOCU, @CSCO_USUA_MODI,@CDFE_USUA_MODI      
  End      
  Close CT_TMDOCU_CLIE_U02_1      
  Deallocate CT_TMDOCU_CLIE_U02_1      
End      
/*------------------------ Fin ----------------------*/  

GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_AF__0B9CA70C] CHECK NOT FOR REPLICATION (([ST_AFEC_IISC]='N' OR [ST_AFEC_IISC]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_AF__0D84EF7E] CHECK NOT FOR REPLICATION (([ST_AFEC_PERC]='N' OR [ST_AFEC_PERC]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_AF__6482D9EB] CHECK NOT FOR REPLICATION (([ST_AFEC_GAFI]='N' OR [ST_AFEC_GAFI]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_AF__666B225D] CHECK NOT FOR REPLICATION (([ST_AFEC_MORA]='N' OR [ST_AFEC_MORA]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_AF__68536ACF] CHECK NOT FOR REPLICATION (([ST_AFEC_FLET]='N' OR [ST_AFEC_FLET]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_CO__08C03A61] CHECK NOT FOR REPLICATION (([ST_CONT]='P' OR [ST_CONT]='N'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_DC__1249A49B] CHECK NOT FOR REPLICATION (([ST_DCT1_BREX]='N' OR [ST_DCT1_BREX]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_DC__1431ED0D] CHECK NOT FOR REPLICATION (([ST_DCT2_BREX]='N' OR [ST_DCT2_BREX]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_DC__6A3BB341] CHECK NOT FOR REPLICATION (([ST_DCT1_BRAF]='N' OR [ST_DCT1_BRAF]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_DC__6C23FBB3] CHECK NOT FOR REPLICATION (([ST_DCT1_BRIN]='N' OR [ST_DCT1_BRIN]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_DC__6E0C4425] CHECK NOT FOR REPLICATION (([ST_DCT1_GAFI]='N' OR [ST_DCT1_GAFI]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_DC__6FF48C97] CHECK NOT FOR REPLICATION (([ST_DCT1_MORA]='N' OR [ST_DCT1_MORA]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_DC__71DCD509] CHECK NOT FOR REPLICATION (([ST_DCT1_FLET]='N' OR [ST_DCT1_FLET]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_DC__73C51D7B] CHECK NOT FOR REPLICATION (([ST_DCT2_BRAF]='N' OR [ST_DCT2_BRAF]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_DC__75AD65ED] CHECK NOT FOR REPLICATION (([ST_DCT2_BRIN]='N' OR [ST_DCT2_BRIN]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_DC__7795AE5F] CHECK NOT FOR REPLICATION (([ST_DCT2_GAFI]='N' OR [ST_DCT2_GAFI]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_DC__797DF6D1] CHECK NOT FOR REPLICATION (([ST_DCT2_MORA]='N' OR [ST_DCT2_MORA]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] WITH NOCHECK ADD CONSTRAINT [CK__TMDOCU_CL__ST_DC__7B663F43] CHECK NOT FOR REPLICATION (([ST_DCT2_FLET]='N' OR [ST_DCT2_FLET]='S'))
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] ADD CONSTRAINT [PK__TMDOCU_C__F95F033641648637] PRIMARY KEY CLUSTERED  ([CO_EMPR], [CO_CLIE], [CO_TIPO_DOCU], [NU_DOCU_CLIE]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] ADD CONSTRAINT [FK__TMDOCU_CL__CO_EM__7ABCFF24] FOREIGN KEY ([CO_EMPR]) REFERENCES [dbo].[TMPARA_TESO] ([CO_EMPR])
GO
ALTER TABLE [dbo].[TMDOCU_CLIE] ADD CONSTRAINT [FK__TMDOCU_CLIE__79C8DAEB] FOREIGN KEY ([CO_EMPR], [TI_VENT]) REFERENCES [dbo].[TTTIPO_VETE] ([CO_EMPR], [TI_VENT])
GO
